package com.zzyy.study.controller;

import com.zzyy.study.service.TongYiService;
import jakarta.annotation.Resource;
import org.springframework.ai.image.ImageResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

/**
 * @auther zzyy
 * @create 2024-06-15 23:39
 */
@RestController
@CrossOrigin
public class TongYiController
{
    @Resource
    private TongYiService tongYiService;

    //http://localhost:24616/ai/simple?message=%E4%BB%8B%E7%BB%8D%E4%B8%80%E4%B8%8B%E5%A4%AB%E5%A6%BB%E8%82%BA%E7%89%87
    @GetMapping("/ai/simple")
    public String completion(@RequestParam("message") String message)
    {
        return tongYiService.completion(message);
    }

    //http://localhost:24616/ai/genImg?imgPrompt=画一只蝴蝶
    @GetMapping("/ai/genImg")
    public ImageResponse genImg(@RequestParam("imgPrompt") String imgPrompt)
    {
        return tongYiService.genImg(imgPrompt);
    }
}